using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_Hotel {
		#region Fields
		private int iD;
		private int hotelID;
		private string name;
		private string description;
		private string detail;
		private string imageURL;
		private int cityID;
		private int lanuageId;
		private int star;
		private int rating;
		private string address;
		private string telephone;
		private string fax;
		private string openTime;
		private int unitPrice;
		private string overView;
		private string uRL;
		private string locCode;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_Hotel class.
		/// </summary>
		public TF_Hotel() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Hotel class.
		/// </summary>
		public TF_Hotel(int hotelID, string name, string description, string detail, string imageURL, int cityID, int lanuageId, int star, int rating, string address, string telephone, string fax, string openTime, int unitPrice, string overView, string uRL, string locCode) {
			this.hotelID = hotelID;
			this.name = name;
			this.description = description;
			this.detail = detail;
			this.imageURL = imageURL;
			this.cityID = cityID;
			this.lanuageId = lanuageId;
			this.star = star;
			this.rating = rating;
			this.address = address;
			this.telephone = telephone;
			this.fax = fax;
			this.openTime = openTime;
			this.unitPrice = unitPrice;
			this.overView = overView;
			this.uRL = uRL;
			this.locCode = locCode;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Hotel class.
		/// </summary>
		public TF_Hotel(int iD, int hotelID, string name, string description, string detail, string imageURL, int cityID, int lanuageId, int star, int rating, string address, string telephone, string fax, string openTime, int unitPrice, string overView, string uRL, string locCode) {
			this.iD = iD;
			this.hotelID = hotelID;
			this.name = name;
			this.description = description;
			this.detail = detail;
			this.imageURL = imageURL;
			this.cityID = cityID;
			this.lanuageId = lanuageId;
			this.star = star;
			this.rating = rating;
			this.address = address;
			this.telephone = telephone;
			this.fax = fax;
			this.openTime = openTime;
			this.unitPrice = unitPrice;
			this.overView = overView;
			this.uRL = uRL;
			this.locCode = locCode;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the HotelID value.
		/// </summary>
		public int HotelID {
			get { return hotelID; }
			set { hotelID = value; }
		}
		
		/// <summary>
		/// Gets or sets the Name value.
		/// </summary>
		public string Name {
			get { return name; }
			set { name = value; }
		}
		
		/// <summary>
		/// Gets or sets the Description value.
		/// </summary>
		public string Description {
			get { return description; }
			set { description = value; }
		}
		
		/// <summary>
		/// Gets or sets the Detail value.
		/// </summary>
		public string Detail {
			get { return detail; }
			set { detail = value; }
		}
		
		/// <summary>
		/// Gets or sets the ImageURL value.
		/// </summary>
		public string ImageURL {
			get { return imageURL; }
			set { imageURL = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityID value.
		/// </summary>
		public int CityID {
			get { return cityID; }
			set { cityID = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanuageId value.
		/// </summary>
		public int LanuageId {
			get { return lanuageId; }
			set { lanuageId = value; }
		}
		
		/// <summary>
		/// Gets or sets the Star value.
		/// </summary>
		public int Star {
			get { return star; }
			set { star = value; }
		}
		
		/// <summary>
		/// Gets or sets the Rating value.
		/// </summary>
		public int Rating {
			get { return rating; }
			set { rating = value; }
		}
		
		/// <summary>
		/// Gets or sets the Address value.
		/// </summary>
		public string Address {
			get { return address; }
			set { address = value; }
		}
		
		/// <summary>
		/// Gets or sets the Telephone value.
		/// </summary>
		public string Telephone {
			get { return telephone; }
			set { telephone = value; }
		}
		
		/// <summary>
		/// Gets or sets the Fax value.
		/// </summary>
		public string Fax {
			get { return fax; }
			set { fax = value; }
		}
		
		/// <summary>
		/// Gets or sets the OpenTime value.
		/// </summary>
		public string OpenTime {
			get { return openTime; }
			set { openTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the UnitPrice value.
		/// </summary>
		public int UnitPrice {
			get { return unitPrice; }
			set { unitPrice = value; }
		}
		
		/// <summary>
		/// Gets or sets the OverView value.
		/// </summary>
		public string OverView {
			get { return overView; }
			set { overView = value; }
		}
		
		/// <summary>
		/// Gets or sets the URL value.
		/// </summary>
		public string URL {
			get { return uRL; }
			set { uRL = value; }
		}
		
		/// <summary>
		/// Gets or sets the LocCode value.
		/// </summary>
		public string LocCode {
			get { return locCode; }
			set { locCode = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_Hotel table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_HotelInsert", hotelID, name, description, detail, imageURL, cityID, lanuageId, star, rating, address, telephone, fax, openTime, unitPrice, overView, uRL, locCode));
		}
		
		/// <summary>
		/// Updates a record in the TF_Hotel table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_HotelUpdate", iD, hotelID, name, description, detail, imageURL, cityID, lanuageId, star, rating, address, telephone, fax, openTime, unitPrice, overView, uRL, locCode);
		}
		
		/// <summary>
		/// Deletes a record from the TF_Hotel table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_HotelDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_Hotel table.
		/// </summary>
		public static TF_Hotel Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_HotelSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_Hotel(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_Hotel table.
		/// </summary>
		public static List<TF_Hotel> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_HotelSelectAll")) {
				List<TF_Hotel> tF_HotelList = new List<TF_Hotel>();
				while (dataReader.Read()) {
					TF_Hotel tF_Hotel = MakeTF_Hotel(dataReader);
					tF_HotelList.Add(tF_Hotel);
				}
				return tF_HotelList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_Hotel class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_Hotel MakeTF_Hotel(SqlDataReader dataReader) {
			TF_Hotel tF_Hotel = new TF_Hotel();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_Hotel.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_Hotel.HotelID = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_Hotel.Name = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_Hotel.Description = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_Hotel.Detail = dataReader.GetString(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_Hotel.ImageURL = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_Hotel.CityID = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_Hotel.LanuageId = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_Hotel.Star = dataReader.GetInt32(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_Hotel.Rating = dataReader.GetInt32(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_Hotel.Address = dataReader.GetString(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_Hotel.Telephone = dataReader.GetString(11);
			}
			if (dataReader.IsDBNull(12) == false) {
				tF_Hotel.Fax = dataReader.GetString(12);
			}
			if (dataReader.IsDBNull(13) == false) {
				tF_Hotel.OpenTime = dataReader.GetString(13);
			}
			if (dataReader.IsDBNull(14) == false) {
				tF_Hotel.UnitPrice = dataReader.GetInt32(14);
			}
			if (dataReader.IsDBNull(15) == false) {
				tF_Hotel.OverView = dataReader.GetString(15);
			}
			if (dataReader.IsDBNull(16) == false) {
				tF_Hotel.URL = dataReader.GetString(16);
			}
			if (dataReader.IsDBNull(17) == false) {
				tF_Hotel.LocCode = dataReader.GetString(17);
			}

			return tF_Hotel;
		}
		#endregion
	}
}
